<template>
  <div>
    <el-card>
      <template #header>
        <div class="card-header">
          <span>{{ $t('publishNotification') }}</span>
        </div>
      </template>
      
      <el-form :model="form" label-width="120px" style="max-width: 600px">
        <el-form-item :label="$t('notificationTitle')">
          <el-input v-model="form.title" :placeholder="$t('pleaseEnter') + $t('notificationTitle')" />
        </el-form-item>
        
        <el-form-item :label="$t('notificationContent')">
          <el-input
            v-model="form.content"
            type="textarea"
            :rows="6"
            :placeholder="$t('pleaseEnter') + $t('notificationContent')"
          />
        </el-form-item>
        
        <el-form-item :label="$t('targetAudience')">
          <el-select v-model="form.target" :placeholder="$t('pleaseSelect') + $t('targetAudience')">
            <el-option :label="$t('allUsers')" value="all" />
            <el-option :label="$t('volunteers')" value="volunteer" />
            <el-option :label="$t('elderly')" value="elderly" />
          </el-select>
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" @click="handleSubmit">{{ $t('publish') }}</el-button>
          <el-button @click="handleReset">{{ $t('reset') }}</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { ElMessage } from 'element-plus';

const { t } = useI18n();

const form = ref({
  title: '',
  content: '',
  target: ''
});

const handleSubmit = () => {
  if (!form.value.title || !form.value.content || !form.value.target) {
    ElMessage.warning(t('pleaseCompleteAllFields'));
    return;
  }
  
  // 这里添加发布通知的逻辑
  console.log('发布通知:', form.value);
  ElMessage.success(t('notificationPublishedSuccessfully'));
  handleReset();
};

const handleReset = () => {
  form.value = {
    title: '',
    content: '',
    target: ''
  };
};
</script>

<style scoped>
.notify-add {
  padding: 20px;
}

.card-header {
  font-weight: bold;
  font-size: 16px;
}
</style>
